package org.example.auth.model.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.example.misc.model.CommonEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "auth_user_role")
@org.hibernate.annotations.Table(appliesTo = "auth_user_role", comment = "用户角色表")
@Getter
@Setter
@NoArgsConstructor
public class UserRole implements Serializable {
    private static final long serialVersionUID = -5648954235867074158L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    private Long id;

    @Column(nullable = false)
    private Long userId;

    @Column(nullable = false)
    private Long roleId;
    /**
     * 默认角色
     */
    @Column(nullable = false)
    private Boolean defaultFlag;

    @Embedded
    private CommonEntity commonInfo;


    public UserRole(Long userId, Long roleId) {
        this.userId = userId;
        this.roleId = roleId;
    }
}
